package com.ruoyi.web.controller.mes;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.kt.mes.domain.ProlSiteSet;
import com.kt.mes.service.IProlSiteSetService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * opc设置Controller
 *
 * @author lzc
 * @date 2021-01-13
 */
@RestController
@RequestMapping("/mes/opc_set")
public class ProlSiteSetController extends BaseController
{
    @Autowired
    private IProlSiteSetService prolSiteSetService;

    /**
     * 查询opc设置列表
     */
    @PreAuthorize("@ss.hasPermi('mes:opc_set:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProlSiteSet prolSiteSet)
    {
        startPage();
        List<ProlSiteSet> list = prolSiteSetService.selectProlSiteSetList(prolSiteSet);
        return getDataTable(list);
    }

    /**
     * 导出opc设置列表
     */
    @PreAuthorize("@ss.hasPermi('mes:opc_set:export')")
    @Log(title = "opc设置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ProlSiteSet prolSiteSet)
    {
        List<ProlSiteSet> list = prolSiteSetService.selectProlSiteSetList(prolSiteSet);
        ExcelUtil<ProlSiteSet> util = new ExcelUtil<ProlSiteSet>(ProlSiteSet.class);
        return util.exportExcel(list, "opc_set");
    }

    /**
     * 获取opc设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('mes:opc_set:query')")
    @GetMapping(value = "/{prolSiteId}")
    public AjaxResult getInfo(@PathVariable("prolSiteId") Long prolSiteId)
    {
        return AjaxResult.success(prolSiteSetService.selectProlSiteSetById(prolSiteId));
    }

    /**
     * 新增opc设置
     */
    @PreAuthorize("@ss.hasPermi('mes:opc_set:add')")
    @Log(title = "opc设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProlSiteSet prolSiteSet)
    {
        return toAjax(prolSiteSetService.insertProlSiteSet(prolSiteSet));
    }

    /**
     * 修改opc设置
     */
  //  @PreAuthorize("@ss.hasPermi('mes:opc_set:edit')")
    @Log(title = "opc设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProlSiteSet prolSiteSet)
    {
        return toAjax(prolSiteSetService.updateProlSiteSet(prolSiteSet));
    }

    /**
     * 删除opc设置
     */
    @PreAuthorize("@ss.hasPermi('mes:opc_set:remove')")
    @Log(title = "opc设置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{prolSiteIds}")
    public AjaxResult remove(@PathVariable Long[] prolSiteIds)
    {
        return toAjax(prolSiteSetService.deleteProlSiteSetByIds(prolSiteIds));
    }
}
